<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 参数默认值
    // function fn(a, b = 100) {
    //   console.log(a, b)
    // }
    // fn(1, 2)


    // 剩余参数
    // function fn2(a, b, ...args) {
    //   // console.log(arguments)
    //   console.log(a, b, args)
    // }
    // fn2(1,2,3,4,5,6)

    // 箭头函数
    var user = '小红'

    const obj = {
      user: '小明',
      say() {
        console.log(this.user)
        return function() {
          console.log(this.user)
        }
      },
      say1() {
        console.log(this.user)
        return () => {
          // 箭头函数中的this指向定义时所在作用域的this
          console.log(this.user)
        }
      },
      say2: () => {
        console.log(this.user)
        return function () {
          console.log(this.user)
        }
      }
    }

    // const f = obj.say()
    // f()

    // const f = obj.say1()
    // f()

    // const f1 = obj.say1
    // const f2 = f1()
    // f2()

    const f = obj.say2()
    f()





  </script>
</body>
</html>